import random

ran = random.randint(0, 100)
core = 5000
guess = int(input("请猜一个0到100的整数数字："))
while core != 0:
    if guess > ran:
        print("大了减500金币")
        core -= 500
        print(f"还剩{core}个金币")
        if core != 0:
            guess = int(input("再猜一次："))
    elif guess < ran:
        print("小了减500金币")
        core -= 500
        print(f"还剩{core}个金币")
        if core != 0:
            guess = int(input("再猜一次："))
    else:
        print("恭喜猜中＋3000个金币，本轮幸运数字为：", guess)
        core += 3000
        print(f"还剩{core}个金币")
        game = int(input("是否继续下一轮游戏，输入1继续下一轮游戏，输入0结束游戏："))
        while game != 1 and 0:
            game = int(input("输入错误请重新输入："))
        if game == 1:
            guess = int(input("请重新猜一个0到100的整数数字："))
            ran = random.randint(0, 100)
            continue
        elif game == 0:
            break
print("游戏结束！")
